<?php

class Admin_Models_Site extends Fengqiaoju_Db_Table {
	
	/**
	 * 模块表
	 * @var unknown_type
	 */
	private $_table_model = 'site_model';

	public function __construct() {

		parent::__construct ();
		$this->_name = $this->_prefix . "site";
		$this->_primary = "site_id";
		$this->_table_model = $this->_prefix . $this->_table_model;
	}

	/**
	 * 创建小站
	 */
	public function cerateSite($data) {

		$site ['site_name'] = $data ['site_name'];
		$site ['site_seo_name'] = $data ['site_seo_name'];
		$site ['site_intro'] = $data ['site_intro'];
		$site ['category_id'] = $data ['category_id'];
		$site_id = $this->insert ( $site );
		
		$model ['model_name'] = $data ['model_name'];
		$model ['site_id'] = $site_id;
		$model ['model_type'] = $data ['model_type'];
		$model ['model_intro'] = $data ['model_intro'];
		
		$this->createModel ( $model );
		
		return $site_id;
	
	}

	/**
	 * 编辑小站
	 */
	public function updateSite($data , $where) {

		$where = $this->arrayToString ( $where );
		return $this->update ( $data, $where );
	}

	/**
	 * 创建模块
	 */
	public function createModel($data) {

		$model ['model_name'] = $data ['model_name'];
		$model ['site_id'] = $data ['site_id'];
		$model ['model_type'] = $data ['model_type'];
		$model ['model_intro'] = $data ['model_intro'];
		$model ['show_index'] = $data ['show_index'];
		return $this->_db->insert ( $this->_table_model, $model );
	}

	/**
	 * 获取小站列表
	 */
	public function getSiteList($where , $order = '') {

		$where = $this->arrayToString ( $where );
		return $this->fetchAll ( $where, $order );
	}

	/**
	 * 获取小站信息
	 */
	public function getSiteInfo($where) {

		$where = $this->arrayToString ( $where );
		return $this->fetchRow ( $where );
	}
}